//
//  LCCompanyViewController.m
//  EnterpriseCloud
//
//  Created by 东亨 on 2017/7/10.
//  Copyright © 2017年 lichao. All rights reserved.
//

#import "LCCompanyViewController.h"
#import "LCWebTableViewCell.h"
#import "CountHeight.h"
#import "EnterpriseModel.h"
static NSString *cellidentifier = @"LCWebTableViewCell";

@interface LCCompanyViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) IBOutlet UIView *headView;
@property (weak, nonatomic) IBOutlet UIImageView *enterImg;
@property (weak, nonatomic) IBOutlet UILabel *enterTitle;
@property (weak, nonatomic) IBOutlet UILabel *enterPhone;
@property (weak, nonatomic) IBOutlet UILabel *enterCount;
@property (weak, nonatomic) IBOutlet UILabel *enterIndue;
@property (strong,nonatomic)NSMutableDictionary  *dataDic;
@property (strong,nonatomic)EnterpriseModel     *enterModel;

@end
@implementation LCCompanyViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setBarTitle:@"企业信息展示"];
    _dataDic = [[NSMutableDictionary alloc]initWithCapacity:0];
    if (get_sp(@"app_user"))
    {
        NSDictionary  *companyDic = [NSDictionary dictionaryWithDictionary:get_sp(@"company")];
        NSString *imgUrl = [NSString stringWithFormat:@"%@/%@%@",ENCLOUD_URL,companyDic[@"file_path"],companyDic[@"file_name"]];
        [self.enterImg sd_setImageWithURL:[NSURL URLWithString:imgUrl]];
     }
    [self loadCustomeView];
    [self loadData];
}
- (void)loadCustomeView
{
    _tableView.delegate = self;
    _tableView.dataSource = self;
    CGFloat  height = SCREEN_WIDTH*(232.0/375)+25+24+18+18+20;
    _headView.frame = CGRectMake(0, 0, SCREEN_WIDTH, height);
    _tableView.tableHeaderView = _headView;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_tableView registerNib:[UINib nibWithNibName:@"LCWebTableViewCell" bundle:nil] forCellReuseIdentifier:cellidentifier];
}
-(void)loadData
{
    [_dataDic setObject:@"1" forKey:@"company_id"];
    [MDataProvider getEnterpriseMessageBodyDic:_dataDic sucess:^(EnterpriseModel *detailModel) {
        _enterModel = detailModel;
        _enterTitle.text = _enterModel.company_name;
        _enterPhone.text = _enterModel.legal_phone;
        _enterCount.text = _enterModel.employee_num;
        _enterIndue.text = _enterModel.industry_name;
        [_tableView reloadData];
        
    } faile:^(NSString *str) {
        
    }];
}
#pragma mark -UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LCWebTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellidentifier];
    if (_enterModel.summary)
    {
        [cell.webView loadHTMLString:_enterModel.summary baseURL:nil];
    }
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return SCREEN_HEIGHT-107-64;
}
@end
